package com.lobo.blog.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: MacieSerenity
 * Date: 2020/04/26 14:44
 * Description:
 * Version: V1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Comment {
    private Integer id;
    private String nickname;
    private String email;
    private String content;
    //    头像
    @NestedConfigurationProperty
    private String avatar;
    //    生成全时间，日期及加时间
    private Date createTime;
    private Blog blog;
    private Boolean isAdmin;



    //    评论关系映射
    //    一个父评论可以有多个子评论
    private List<Comment> replyComments = new ArrayList<>();

    //    一个子评论只能有一个父评论
    private Comment parentComment;
    private Integer parentCommentId;
    private Integer blogId;

    private Integer topCommentId;

    public Comment(Comment comment) {
        this.id=comment.getId();
        this.nickname=comment.getNickname();
        this.email=comment.getEmail();
        this.content=comment.getContent();
        this.avatar=comment.getAvatar();
        this.createTime=comment.getCreateTime();
        this.blog=comment.getBlog();
        this.isAdmin=comment.getIsAdmin();
        this.replyComments=comment.getReplyComments();
        this.parentComment=comment.getParentComment();
        this.parentCommentId=comment.getParentCommentId();
        this.blogId=comment.getBlogId();
        this.topCommentId=comment.getTopCommentId();
    }
}
